﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Crazycrash.UI
{
    public partial class Animalpanel : UserControl
    {
        public int x;
        public int y;
        public Int16 SIZE = 40;
        public Gamepanel fatherpanel;
        public Animalpanel()
        {
            InitializeComponent();
        }
        private void Animalpanel_Click(object sender, EventArgs e)
        {
            if (Gamepanel.firstselected == null && Gamepanel.secondselected == null)
            {
                Gamepanel.firstselected = this;//若没有方块被选择
            }
            else if (Gamepanel.firstselected != null && Gamepanel.secondselected == null)
            {
                if ((Math.Abs(Gamepanel.firstselected.x - this.x) + Math.Abs(Gamepanel.firstselected.y - this.y)) == 1)//如果选择的两个是相邻的
                {
                    Gamepanel.secondselected = this;
                    fatherpanel.swap2tiles();
                }
                else
                {
                    Gamepanel.firstselected = null;
                }
            }
        }
    }
}
